package com.hong.order;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class OrderCodeGenerator {

    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss-");

    //自增序列
    private int sequence;

    /**
     * 订单编号生成，格式：yyyy-MM-dd-HH-mm-ss-sequence
     * @return
     */
    public String generateCode(){
        LocalDateTime now = LocalDateTime.now();
        return now.format(FORMATTER) + (++sequence);
    }

}
